//
// Created by ze on 2023/11/9.
//

#include "UPRE_GLOBAL_DEFINE.h"
#include "UPRE_GYRO.h"
#include "UPRE_PID.h"
#include "UPRE_LOCATION.h"
#include "can.h"
#include "tim.h"
#include "stm32f4xx_it.h"
#include "Bsp_CAN.h"
#include "Kalmanfilter.h"
extern uint8_t buffer1[250];
int _write(int file, char *data, int len)
{
    HAL_UART_Transmit(&huart3, (uint8_t*)data, len, HAL_MAX_DELAY);
    return len;
}
void Robot_Init()
{
//    static uint8_t Temp = 0;
//    HAL_UART_Receive_IT(&huart6, &Temp, 1);  //使�?��?��???��??
    extern uint8_t USART1_RX[100];
    __HAL_UART_ENABLE_IT(&huart1,UART_IT_IDLE);
    HAL_UART_Receive_DMA(&huart1,USART1_RX,19);

//    __HAL_UART_ENABLE_IT(&huart1,UART_IT_IDLE);
//    HAL_UART_Receive_DMA(&huart1,buffer1,100);

    //陀螺仪初始化
    GYRO_MINS500_Init();
    //PID初始化
    pidInit();
    //全场定位编码器初始化
    HAL_TIM_Encoder_Start(&htim1,TIM_CHANNEL_ALL);
    HAL_TIM_Encoder_Start(&htim4,TIM_CHANNEL_ALL);
    Location_Init();
    //电机初始化
//    CAN_filter_init();
    //蓝牙初始化
//static uint8_t temp = 0;
//    HAL_UART_Receive_IT(&huart3,&temp,1);
    //串口一初始化
    //DT35初始化
    DT35_Init();
}